import request from '@/utils/request'

export default{
    getProductList(searchModel){
        return request({
          url: '/product/list',
          method: 'get',
          params: {
            name: searchModel.name,
            type: searchModel.type,
            pageNo: searchModel.pageNo,
            pageSize: searchModel.pageSize
          }
        });
      },
      // 新增
      addProduct(product){
        return request({
          url: '/product',
          method: 'post',
          data: product
        });
      },
      // 修改
      updateProduct(product){
        return request({
          url: '/product',
          method: 'put',
          data: product
        });
      },
      // 保存角色数据
      saveProduct(product){
        if(product.id == null || product.id == undefined){
          return this.addProduct(product);
        }
        return this.updateProduct(product);
      },
      // 根据id查询
      getProductById(id){
        return request({
          url: `/product/${id}`,
          method: 'get'
        });
      },
}
